<?php

namespace App\Models;

use App\Models\Traits\ProjectTrait;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Cell
 *
 * @property int $id
 * @property int $project_id 项目ID
 * @property int $column_id 列ID
 * @property int $row_id 行ID
 * @property string $type 内容类型
 * @property string $content 内容
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell query()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell whereColumnId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell whereContent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell whereProjectId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell whereRowId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Cell whereUpdatedAt($value)
 * @mixin \Eloquent
 * @property-read \App\Models\Column $column
 * @property-read \App\Models\Project $project
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\CellProp[] $props
 * @property-read int|null $props_count
 * @property-read \App\Models\Row $row
 */
class Cell extends Model
{

    use ProjectTrait;

    protected $fillable = [
        'project_id', 'column_id', 'row_id', 'type', 'content'
    ];

    public function props()
    {
        return $this->hasMany(CellProp::class);
    }

    public function row()
    {
        return $this->belongsTo(Row::class);
    }

    public function column()
    {
        return $this->belongsTo(Column::class);
    }
}
